//
//  LTFFifthTableVIewCell.m
//  NeteaseNews
//
//  Created by liutaifeng on 16/4/27.
//  Copyright © 2016年 liutaifeng. All rights reserved.
//

#import "LTFFifthTableVIewCell.h"
#import "UIImageView+AFNetworking.h"
#import "AFNetworking.h"
#import "IsNight.h"
#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@interface LTFFifthTableVIewCell ()
@property (nonatomic, retain) UIView *myView;
@property (nonatomic, retain) UIImageView *firstImageView;
@property (nonatomic, retain) UIImageView *secondImageView;
@property (nonatomic, retain) UIImageView *thirdImageView;
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *replyLabel;
@property (nonatomic, retain) UILabel *picCountLabel;
@property (nonatomic, retain) UIView *backView;
@end
@implementation LTFFifthTableVIewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView {
    self.model = [[LTFBeautyModel alloc] init];
    //背景
    self.myView = [[UIView alloc] init];
    [self.contentView addSubview:_myView];
    //_myView.backgroundColor = [UIColor redColor];
    [_myView release];
    //图片
    self.firstImageView = [[UIImageView alloc] init];
    //_picImageView.backgroundColor = [UIColor whiteColor];
    [_myView addSubview:_firstImageView];
    [_firstImageView release];
    //图片
    self.secondImageView = [[UIImageView alloc] init];
    //_picImageView.backgroundColor = [UIColor whiteColor];
    [_myView addSubview:_secondImageView];
    [_secondImageView release];
    //图片
    self.thirdImageView = [[UIImageView alloc] init];
    //_picImageView.backgroundColor = [UIColor whiteColor];
    [_myView addSubview:_thirdImageView];
    [_thirdImageView release];
    //标题
    self.titleLabel = [[UILabel alloc] init];
    //_titleLabel.backgroundColor = [UIColor whiteColor];
    [_myView addSubview:_titleLabel];
    [_titleLabel release];
    
    //回复
    self.replyLabel = [[UILabel alloc] init];
    [_myView addSubview:_replyLabel];
    [_replyLabel release];
    //beijing
    self.backView = [[UIView alloc] init];
    [_myView addSubview:_backView];
    [_backView release];
    //图片数
    self.picCountLabel = [[UILabel alloc] init];
    [_myView addSubview:_picCountLabel];
    [_picCountLabel release];
    
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    if ([IsNight nowIsNight]) {
        self.contentView.backgroundColor = [IsNight nightColor];
        _myView.backgroundColor = [IsNight nightColor];
        _titleLabel.textColor = [IsNight textNightColor];
        _replyLabel.textColor = [IsNight textNightColor];
        _backView.backgroundColor = [IsNight nightColor];
        _picCountLabel.textColor = [IsNight textNightColor];
        
    }
    else {
        self.contentView.backgroundColor = [UIColor whiteColor];
        _myView.backgroundColor = [UIColor whiteColor];
        _titleLabel.textColor = [UIColor blackColor];
        _replyLabel.textColor = [UIColor blackColor];
        _backView.backgroundColor = [UIColor whiteColor];
        _picCountLabel.textColor = [UIColor blackColor];
    }
    _myView.frame = CGRectMake(2, 2, WIDTH - 4, HEIGHT - 4);
    _myView.layer.borderWidth = 1;
    _myView.layer.cornerRadius = 2;
    self.firstImageView.frame = CGRectMake(1, 1, (WIDTH - 6) / 5 * 3 , HEIGHT / 5 * 4);
    self.secondImageView.frame = CGRectMake((WIDTH - 6) / 5 * 3 + 2, 1, (WIDTH - 6) / 5 * 2 - 4, HEIGHT / 5 * 2 - 1);
    self.thirdImageView.frame = CGRectMake((WIDTH - 6) / 5 * 3 + 2, HEIGHT / 5 * 2 + 1, (WIDTH - 6) / 5 * 2 - 4, HEIGHT / 5 * 2 - 1);
    [_firstImageView setImageWithURL:[NSURL URLWithString:self.model.pics[0]] placeholderImage:[UIImage imageNamed:@"zhanwei.png"]];
    [_secondImageView setImageWithURL:[NSURL URLWithString:self.model.pics[1]] placeholderImage:[UIImage imageNamed:@"zhanwei.png"]];
    [_thirdImageView setImageWithURL:[NSURL URLWithString:self.model.pics[2]] placeholderImage:[UIImage imageNamed:@"zhanwei.png"]];
    _titleLabel.frame = CGRectMake(5, (HEIGHT - 4) / 5 * 4 + 3, WIDTH / 3 * 2, (HEIGHT - 4) / 5 - 10);
    _titleLabel.text = self.model.setname;
    _replyLabel.frame = CGRectMake(WIDTH  - 107, (HEIGHT - 4) / 5 * 4 + 2, 80, (HEIGHT - 4) / 5 - 10);
    _replyLabel.text = [NSString stringWithFormat:@"%@跟帖", self.model.replynum];
    _replyLabel.textAlignment = NSTextAlignmentRight;
    _replyLabel.textColor = [UIColor lightGrayColor];
    _replyLabel.font = [UIFont systemFontOfSize:15];
    
    
    _backView.frame = CGRectMake(WIDTH  - 77, (HEIGHT - 4) / 5 * 4 - 40, 60, (HEIGHT - 4) / 5 - 20);
    _backView.backgroundColor = [UIColor blackColor];
    _backView.alpha = 0.5;
    _backView.layer.cornerRadius = 2;
    
    _picCountLabel.frame = CGRectMake(WIDTH  - 77, (HEIGHT - 4) / 5 * 4 - 40, 60, (HEIGHT - 4) / 5 - 20);
    _picCountLabel.text = [NSString stringWithFormat:@"%@pics", self.model.imgsum];
    _picCountLabel.textColor = [UIColor whiteColor];
    _picCountLabel.textAlignment = NSTextAlignmentCenter;
    _picCountLabel.font = [UIFont systemFontOfSize:15];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
